package huanzhao.erp.domain.types;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;

/**
 * @author April
 * 2024/10/4 10:31
 * @version 1.0
 */
@Getter
public enum BillType {
    AMOUNT_ADJUST("金额调整"),
    PURCHASE_PHONE("购买手机支出"),
    PURCHASE_RETURN("采购退货收入"),
    REPAIR_COST("维修成本支出"),
    SALES_INCOME("销售收入"),
    SALES_RETURN("买家退货支出");

    @EnumValue
    @JsonValue
    private final String value;

    BillType(String value) {
        this.value = value;
    }

    /**
     * 根据财务结算类型获取账单类型
     *
     * @param type 财务结算类型
     * @return BillType
     * 2024/10/14 11:11:32
     */
    public static BillType of(FinanceSettlementType type) {
        return switch (type) {
            case REPAIR_COST -> BillType.REPAIR_COST;
            case PURCHASE_RETURN -> BillType.PURCHASE_RETURN;
            case SALES_INCOME -> BillType.SALES_INCOME;
            case SALES_RETURN -> BillType.SALES_RETURN;
        };
    }

}
